---
id: configuration
title: Outstation Configuration
sidebar_label: OutstationConfig
slug: /api/outstation/configuration
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You create outstations using three types of components:

* Static configuration values
* Callback interfaces
* Transport-specific configuration (e.g., TCP vs. serial parameters)

Let's look at the static configuration required to create an outstation. 

### OutstationConfig

The `OutstationConfig` structure contains the parameters that modify the behavior of the outstation. The generated API documentation provides a definition for each field. All fields have default values except for the master and outstation link addresses. Keep in mind that we didn't optimize these default values for every use case; for example, you may need to adjust the timeout parameters for higher latency links.

<Tabs
groupId="language"
defaultValue="Rust"
values={[
{label: 'Rust', value: 'Rust'},
{label: 'C', value: 'C'},
{label: 'C++', value: 'C++'},
{label: 'Java', value: 'Java'},
{label: 'C#', value: 'C#'},
]}>
<TabItem value="Rust">

```rust
{{#include ../dnp3/examples/outstation.rs:outstation_config}}
```

</TabItem>
<TabItem value="C">

```c
{{#include ../ffi/bindings/c/outstation_example.c:create_outstation_config}}
```

</TabItem>
<TabItem value="C++">

```cpp
{{#include ../ffi/bindings/c/outstation_example.cpp:create_outstation_config}}
```

</TabItem>
<TabItem value="Java">

```java
{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:outstation_config}}
```

</TabItem>
<TabItem value="C#">

```csharp
{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:outstation_config}}
```

</TabItem>
</Tabs>

### EventBufferConfig


The `EventBufferConfig` struct controls the number of events buffered for each type that the outstation can report. During the outstation initialization, space is internally pre-allocated for each type based on this configuration. When all the space in the buffer for a particular type has been used, adding another event will cause the oldest event to be discarded, and the outstation will assert IIN 2.3 (Event Buffer Overflow) per the specification.

When determining how many events to configure, remember that there is a fundamental tradeoff between saving events for future reporting and your memory/CPU usage. Determine your event buffer sizes based on these factors:

* How many measurements the outstation database contains
* How often the measurements change
* How often and for how long the master may be disconnected or otherwise unable to empty the event queues via READ or unsolicited reporting
* How important it is to preserve events for a particular type. 

:::tip
Not all events are created equal. For example, it may be important to capture every binary state transition, while missing an analog or counter value might not matter at all.
:::

<Tabs
groupId="language"
defaultValue="Rust"
values={[
    {label: 'Rust', value: 'Rust'},
    {label: 'C', value: 'C'},
    {label: 'C++', value: 'C++'},
    {label: 'Java', value: 'Java'},
    {label: 'C#', value: 'C#'},
]}>
<TabItem value="Rust">

```rust
{{#include ../dnp3/examples/outstation.rs:event_buffer_config}}
```

</TabItem>
<TabItem value="C">

```c
{{#include ../ffi/bindings/c/outstation_example.c:event_buffer_config}}
```

</TabItem>
<TabItem value="C++">

```cpp
{{#include ../ffi/bindings/c/outstation_example.cpp:event_buffer_config}}
```

</TabItem>
<TabItem value="Java">

```java
{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/OutstationExample.java:event_buffer_config}}
```

</TabItem>
<TabItem value="C#">

```csharp
{{#include ../ffi/bindings/dotnet/examples/outstation/Program.cs:event_buffer_config}}
```

</TabItem>
</Tabs>

:::note
Setting the number of events for a particular type to `0` ensures that you will never record or report events for that type.
:::

